package yxy.apple.util;

public class RuntimeUtility {
	public enum OperationSystem {
		Unknown, Mac, Windows;
	}

	public static interface ShutdownHookable {
		public void shutting();
	}

	public static void addShutdownHook(ShutdownHookable hook) {
		Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
			@Override
			public void run() {
				hook.shutting();
			}
		},"ShutdownHookThread"));
	}

	public static OperationSystem currentOperationSystem() {
		OperationSystem result = OperationSystem.Unknown;
		String os = System.getProperty("os.name");
		if (os.toLowerCase().startsWith("mac")) {
			result = OperationSystem.Mac;
		} else if (os.toLowerCase().startsWith("win")) {
			result = OperationSystem.Windows;
		}
		return result;
	}
}
